package com.jzhao.jpre.model.dao;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

import com.jzhao.jpre.base.RandomGUID;
import com.jzhao.jpre.base.StringPublicDeal;
import com.jzhao.jpre.format.DataObjectType;
import com.jzhao.jpre.model.KBMerchantInfo;
import com.jzhao.jpre.model.KBPosDownSelInfo;
import com.jzhao.jpre.model.PmsMerchantInfo;
import com.jzhao.jpre.model.PmsMerchantPos;
import com.jzhao.jpre.model.PmsPosSignin;

/**
 * 
 * @author hj
 * @2011-11-10
 */
class PosSignMapper implements RowMapper 
{
	public Object mapRow(ResultSet rs, int rowNum) throws SQLException 
	{
		PmsPosSignin sg = new PmsPosSignin();
		sg.setLoginam(rs.getString("loginam"));
        sg.setPasswd(rs.getString("passwd"));
        sg.setUserlevel(rs.getString("userlevel"));
		return sg;
	
    } 
}
public class PmsPosSinginDao 
{
	protected JdbcTemplate jdbcTemplate;
	protected StringPublicDeal strPubDeal;

	public void setDataSource(DataSource dataSource) 
	{
		jdbcTemplate = new JdbcTemplate(dataSource);
	}

	public void setStrPubDeal(StringPublicDeal strPubDeal) 
	{
		this.strPubDeal = strPubDeal;
	}

	public String selectPossingn(String posid,String UserName)
	{
		String sql = "select count(*) numcount from pms_pos_signin a , pms_merchant_pos b " +
					 " where b.POSBUSSINESSNO = '"+posid+"' and a.merposid = b.id and a.LOGINAM = '"+UserName+"'";
		return (String)jdbcTemplate.queryForObject(sql,java.lang.String.class);
	}
	
	public String selectPosPwd(String posid,String UserName,String pwd)
	{
		String sql = "select count(*) numcount from pms_pos_signin a , pms_merchant_pos b " +
					 " where b.POSBUSSINESSNO = '"+posid+"' and a.merposid = b.id and a.LOGINAM = '"+UserName+"'"
					 + "and a.PASSWD = '"+pwd+"'";
		return (String)jdbcTemplate.queryForObject(sql,java.lang.String.class);
	}
	
	public String selectUseStatus(String posid,String UserName)
	{
		String sql = "select a.STATUS  from pms_pos_signin a , pms_merchant_pos b " +
					 " where b.POSBUSSINESSNO = '"+posid+"' and a.merposid = b.id and a.LOGINAM = '"+UserName+"'";
		return (String)jdbcTemplate.queryForObject(sql,java.lang.String.class);
	}
	
	public String existPosuser(String posid,String user)
	{
		String sql = "select count(*) numcount from pms_pos_signin a , pms_merchant_pos b " +
					 " where b.POSBUSSINESSNO = '"+posid+"' and a.merposid = b.id and a.LOGINAM = '" +user+ "'";
		return (String) jdbcTemplate.queryForObject(sql,java.lang.String.class);
	}
}